package com.kk.base.controller.common;

import com.kk.base.util.DownloadUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

/**
 * 文件下载
 */
@Controller
@RequestMapping("/download")
public class DownloadController {

    @Value("${upload.download.path}")
    private String filePath;//文件保存位置

    @Value("${upload.download.name}")
    private String fileName;

    /* *//** * 下载文件 * * @return 成功下载文件，失败返回0 * @throws IOException */
    @GetMapping("/importTemplate")
    public void downloadFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DownloadUtil.downloadFile(filePath,fileName,request,response);
    }

}
